** This do file replicates the analysis reported in chapter 2 of _Logics of War_ and 
** also provides the regressions to conduct additional robustness checks referenced
** in the main analysis.  The relevant datasets (logics_of_war.dta and logics_warcost.dta)
** are assembled from component datasets in a separate do file, data_setup.do.

** This version: 4/22/2013

** The do file first replicates the results reported in the four statistical tables.  I then
** provide the code necessary to generating the figures that appear in the book.  The final
** (and longest) section of the do file conducts the range of robustness checks referenced in 
** the book and reported in the statistical appendix.

clear all
set more off

use logics_of_war, clear

**********************************************************************************

** Reproducing the tables

**********************************************************************************

** Replicating table 2.2

** War duration models

stset durat

stcox pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr

stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr

** Battle deaths models

stset deaths

stcox pa10lag terrain contig relcap nstates durscale majpowboth civclash totalpop if default==1, robust nohr

stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash totalpop if default==1, robust nohr

** Government spending models

use logics_warcost, clear

stset warpc

stcox pa10lag terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr

stcox pa10lag  lnintens deminit terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr





** Replicating table 2.3

use logics_of_war.dta, clear

** Duration model

stset durat
stcox pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr

** Deaths model

stset deaths
stcox pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates durscale majpowboth civclash totalpop if default==1, robust nohr




** Replicating table 2.4

** Duration models

stset durat, f(conquest==0)
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==1)

stcrreg pa10lag lnintens intpa deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==1)

stset durat, f(conquest)

stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==0)

** Death models

stset deaths, f(conquest==0)
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest==1)

stset deaths, f(conquest)
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest==0)

** Government spending models

use logics_warcost, clear

stset warpc, f(conquest==0)
stcrreg pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdppc, robust nohr compete(conquest==1)

stset warpc, f(conquest)
stcrreg pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdppc, robust nohr compete(conquest==0)



** Replicating table 2.5

use logics_of_war, clear

** Strategy models

probit maneuver pa10lag terrain contig relcap nstates majpowboth stratexp irst if default==1, robust

probit maneuver pa10lag demin terrain contig relcap nstates majpowboth stratexp irst if default==1, robust

probit omda pa10lag demin terrain contig relcap nstates majpowboth stratexp irst if default==1, robust

** Conquest models

probit conquest pa10lag terrain contig relcap nstates majpowboth durscale if default==1, robust

probit conquest pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale if default==1, robust

**********************************************************************************

** Reproducing the figures

**********************************************************************************

** Figure 2.1 (left side)

gen months=durat/30

qui stset months
qui stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr

foreach var in lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash {
qui sum `var' if e(sample), d
local `var'val=r(p50)
}
qui sum pa10lag if e(sample), d
local pa10laglo=r(p10)
local pa10laghi=r(p90)

#del ;

stcurve, survival at(pa10lag=`pa10laglo' lnintens=`lnintensval' deminit=`deminitval' lospol=`lospolval' terrain=`terrainval' civclash=`civclashval' 
contig=`contigval' relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') lp(dash)
at2(pa10lag=`pa10laghi' lnintens=`lnintensval' deminit=`deminitval' lospol=`lospolval' terrain=`terrainval' contig=`contigval' civclash=`civclashval' 
relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') graphregion(fcolor(white))
xlabel(12(12)60) r(0 60) legend(label(1 "Power Shift at 10th Percentile") label(2 "Power Shift at 90th Percentile") cols(1))
title("") ytitle("Proportion of Wars Still Ongoing") xtitle(" " "War Duration (months)") lc(black black) outfile(figure2_1_left, replace);
graph save stcurve_durat, replace;
#del cr;

** Figure 2.1 (right side)

gen deathsalt=deaths/1000

qui stset deathsalt
qui stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash totalpop if default==1, robust nohr

foreach var in lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash totalpop {
qui sum `var' if e(sample), d
local `var'val=r(p50)
}
qui sum pa10lag if e(sample), d
local pa10laglo=r(p10)
local pa10laghi=r(p90)

#del ;

stcurve, survival at(pa10lag=`pa10laglo' lnintens=`lnintensval' deminit=`deminitval' lospol=`lospolval' terrain=`terrainval' civclash=`civclashval' 
contig=`contigval' relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval' totalpop=`totalpopval') lp(dash)
at2(pa10lag=`pa10laghi' lnintens=`lnintensval' deminit=`deminitval' lospol=`lospolval' terrain=`terrainval' contig=`contigval' civclash=`civclashval' 
relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval' totalpop=`totalpopval') graphregion(fcolor(white))
xlabel(50(50)250) r(0 250) legend(label(1 "Power Shift at 10th Percentile") label(2 "Power Shift at 90th Percentile") cols(1))
title("") ytitle("Proportion of Wars Reaching Death Total") xtitle(" " "Battle Deaths (thousands)") lc(black black) outfile(figure2_1_right, replace);
graph save stcurve_deaths, replace;
#del cr;

** Figure 2.2

qui stset months
qui stcox pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr

foreach var in pa10lag lnintens deminit terrain contig relcap nstates durscale majpowboth civclash {
qui sum `var' if e(sample), d
local `var'val=r(p50)
}

#del ;

stcurve, survival at(lospol=0 lospol2=0 pa10lag=`pa10lagval' lnintens=`lnintensval' deminit=`deminitval' terrain=`terrainval' civclash=`civclashval'
contig=`contigval' relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval')
at2(lospol=10 lospol2=100 pa10lag=`pa10lagval' lnintens=`lnintensval' deminit=`deminitval' terrain=`terrainval' contig=`contigval' civclash=`civclashval'
relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') lp(shortdash longdash) lc(black black black)
at3(lospol=20 lospol2=400 pa10lag=`pa10lagval' lnintens=`lnintensval' deminit=`deminitval' terrain=`terrainval' contig=`contigval' 
relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') graphregion(fcolor(white))
xlabel(12(12)60) r(0 60) legend(label(1 "Fully Autocratic Loser") label(2 "Partially Democratic Loser") label(3 "Fully Democratic Loser") cols(2))
title("") ytitle("Proportion of Wars Still Ongoing") xtitle(" " "War Duration (months)") outfile(figure2_2, replace);
graph save stcurve_lospol.eps, replace;
#del cr;

** Figure 2.4

qui stset months, f(conquest==0)
qui stcrreg pa10lag lnintens intpa deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, compete(conquest) robust nohr

foreach var in lospol deminit terrain contig relcap nstates durscale majpowboth civclash {
qui sum `var' if e(sample), d
local `var'val=r(p50)
}

qui sum pa10lag if e(sample), d
local pa10lo=r(mean)-r(sd)
local pa10hi=r(mean)+r(sd)
qui sum lnintens if e(sample), d
local intlo=r(mean)-r(sd)
local inthi=r(mean)+r(sd)
local intpa1=`pa10hi'*`inthi'
local intpa2=`pa10lo'*`inthi'
local intpa3=`pa10lo'*`intlo'

#del ;

stcurve, cif at(pa10lag=`pa10lo' lnintens=`inthi' intpa=`intpa2' 
lospol=`lospolval' deminit=`deminitval' terrain=`terrainval' contig=`contigval' relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' civclash=`civclashval'
majpowboth=`majpowbothval') at2(pa10lag=`pa10lo' lnintens=`intlo' intpa=`intpa3' lospol=`lospolval' deminit=`deminitval' terrain=`terrainval' civclash=`civclashval'
contig=`contigval' relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') 
at3(pa10lag=`pa10hi' lnintens=`inthi' intpa=`intpa1' lospol=`lospolval' deminit=`deminitval' terrain=`terrainval' contig=`contigval' civclash=`civclashval'
relcap=`relcapval' nstates=`nstatesval' durscale=`durscaleval' majpowboth=`majpowbothval') lp(shortdash longdash) 
lc(black black black) graphregion(fcolor(white)) xlabel(12(12)60) r(0 60) legend(order(1 3 2) label(1 "High Intensity, Low Shift") 
label(2 "Low Intensity, Low Shift") label(3 "High Intensity, High Shift")) title("") ytitle("Proportion of Wars Ended in Settlement") 
xtitle(" " "War Duration (months)") outfile(figure2_4, replace);

#del cr;

**********************************************************************************

** Robustness checks and appendices

**********************************************************************************

lab var pa10lag "Power Shift"
lab var pa5lag "Power Shift$_{All Part.}^{5 Years}$"
lab var pi10lag "Power Shift$_{Init. Part.}^{10 Years}$"
lab var pi5lag "Power Shift$_{Init. Part.}^{5 Years}$"
lab var pp10lag "Power Shift$_{Primary Dyad}^{10 Years}$"
lab var pp5lag "Power Shift$_{Primary Dyad}^{5 Years}$"
lab var lnintens "log(War Intensity)"
lab var deminit "Dem. Initiator"
lab var deminit6 "Dem. Initiator"
lab var lospol "Loser Regime"
lab var lospol2 "(Loser Regime)$^2$"
lab var terrain "Terrain"
lab var contig "Contiguity"
lab var relcap "Relative Cap."
lab var nstates "\# of war participants"
lab var majpowboth "Major Power War"
lab var majpowin "Major Power in War"
lab var durscale "Military strategy"
lab var civclash "Cultural Difference"
lab var totalpop "Total Population"
lab var demin "Democ. Involvement"
lab var irst "Iron/Steel Production"
lab var polityinit "Initiator Polity"
lab var stratexp "Prior Experience"

********************

** Results are robust to changing the universe of cases

********************

set more off
gen est=.
gen esthi=.
gen estlo=.
gen n=_n
local i=1

forvalues j=1/9 {
gen check`j'=default
}
replace check1=0 if flag==1
replace check2=1 if flag==1
replace check3=0 if flag==2
replace check4=1 if flag==3 & default==0 & warnum!=round(warnum,1)
replace check4=0 if flag==3 & default==1 & warnum==round(warnum,1)
replace check4=1 if warnum==83 /* Russo-Chinese 1900, normally collapsed with Boxer */
replace check5=1 if flag==3 & default==0 & warnum==round(warnum,1)
replace check5=0 if flag==3 & default==1 & warnum!=round(warnum,1)
replace check6=1 if warnum>10 & warnum<11
replace check6=0 if warnum==10
replace check7=1 if flag==4 & default==0 & warnum>11
replace check7=0 if flag==4 & default==1 & warnum>11
replace check8=1 if flag==5
replace check9=0 if flag==5

stset durat
forvalues n=1/9 {
stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if check`n'==1, robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6) title("Model 2.2.2");
 
#del cr;
graph save cases_2.2.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset deaths
forvalues n=1/9 {
stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash totalpop if check`n'==1, robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6) title("Model 2.2.4");
#del cr;
graph save cases_2.4.gph, replace

stset durat, f(conquest==0)
replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if check`n'==1, robust compete(conquest) nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6) title("Model 2.4.1");
#del cr;
graph save cases_4.1.gph, replace

stset durat, f(conquest)
replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if check`n'==1, robust compete(conquest==0) nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6) title("Model 2.4.3") ;
#del cr;
graph save cases_4.3.gph, replace

stset deaths, f(conquest==0)
replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if check`n'==1, robust compete(conquest) nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6)  title("Model 2.4.4");
#del cr;
graph save cases_4.4.gph, replace

stset deaths, f(conquest)
replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if check`n'==1, robust compete(conquest==0) nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6)  title("Model 2.4.5");
#del cr;
graph save cases_4.5.gph, replace

replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
probit maneuver pa10lag demin terrain contig relcap nstates majpowboth stratexp irst if check`n'==1, robust
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6)  title("Model 2.5.2");
#del cr;
graph save cases_5.2.gph, replace

replace est=.
replace esthi=.
replace estlo=.

forvalues n=1/9 {
probit conquest pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale if check`n'==1, robust
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)10)
 xlabel(-6(2)6)  title("Model 2.5.5");
#del cr;
graph save cases_5.5.gph, replace

#del ;
graph combine cases_2.2.gph cases_2.4.gph cases_4.1.gph cases_4.3.gph cases_4.4.gph cases_4.5.gph cases_5.2.gph cases_5.5.gph, 
graphregion(fcolor(white) lcolor(black) lwidth(thick));
#del cr;


graph save cases_pacombined.eps, replace

*******************************************************

** Results are robust to using alternate measures of the pre-war power shift

*******************************************************

gen pa10lagalt1=pa10lag
replace pa10lagalt1=pa5lag if warnum==1 | warnum==43 | warnum==88 | warnum==91 | warnum==103 | warnum==125 | warnum==159 | warnum==157 | warnum==219
gen pa10lagalt2=pa10lag
replace pa10lagalt2=. if warnum==1 | warnum==43 | warnum==88 | warnum==91 | warnum==103 | warnum==125 | warnum==159 | warnum==157 | warnum==219


set more off
replace est=.
replace esthi=.
replace estlo=.

stset durat
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcox `var' lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.2.2");
#del cr;
graph save power_2.2.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset deaths
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcox `var' lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.2.4");
#del cr;
graph save power_2.4.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset durat, f(conquest==0)
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcrreg `var' lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, compete(conquest) robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.4.1");
#del cr;
graph save power_4.1.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset durat, f(conquest)
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcrreg `var' lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, compete(conquest==0) robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.4.3");
#del cr;
graph save power_4.3.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset deaths, f(conquest==0)
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcrreg `var' lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, compete(conquest) robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.4.4");
#del cr;
graph save power_4.4.gph, replace

replace est=.
replace esthi=.
replace estlo=.

stset durat, f(conquest)
foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
stcrreg `var' lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, compete(conquest==0) robust nohr
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.4.5");
#del cr;
graph save power_4.5.gph, replace

replace est=.
replace esthi=.
replace estlo=.

foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
probit maneuver `var' demin terrain contig relcap nstates majpowboth stratexp irst if default==1, robust
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.5.2");
#del cr;
graph save power_5.2.gph, replace

replace est=.
replace esthi=.
replace estlo=.

foreach var in pa10lag pa5lag pi10lag pi5lag pp10lag pp5lag pa10lagalt1 pa10lagalt2 {
probit conquest `var' lnintens deminit lospol terrain contig relcap nstates majpowboth durscale if default==1, robust
do base
}

sum esthi
local hi=r(max)
sum estlo
local lo=r(min)
local boundary=max(`hi', abs(`lo'))

#del ;
twoway (rcap estlo esthi n if est!=., horizontal) 
|| (scatter n est if est!=., msymbol(d)), xline(0) ytitle("Robustness Check") 
xtitle("Confidence Intervals") graphregion(fcolor(white)) 
/*legend(label(1 "Confidence Interval") label(2 "Point Estimate"))*/
legend(off)
ysc(reverse) xscale(range(-`boundary' `boundary')) ymtick(1(1)8)
 xlabel(-6(2)6)  title("Model 2.5.5");
#del cr;
graph save power_5.5.gph, replace

#del ;
graph combine power_2.2.gph power_2.4.gph power_4.1.gph power_4.3.gph power_4.4.gph power_4.5.gph power_5.2.gph power_5.5.gph, 
graphregion(fcolor(white) lcolor(black) lwidth(thick));
#del cr;

*graph save robust_pameasure.eps, replace

************************************************************

** Results are robust to substituting COW duration data

************************************************************

stset cowdurat
stcox pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr
eststo model1
stcox pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr
eststo model2
stcox pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates durscale majpowboth civclash if default==1, robust nohr
eststo model3
stset cowdurat, f(conquest==0)
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
eststo model4
stcrreg pa10lag lnintens intpa deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
eststo model5
stset cowdurat, f(conquest)
stcrreg pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==0)
eststo model6

#del ;
esttab model1 model2 model3 model4 model5 model6 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.1" "2.2.2" "2.3.1" "2.4.1" "2.4.2" "2.4.3") sca(N_fail)
title("Duration Analysis Robustness Checks (COW Duration Data)\label{tab-robust-cowdurat}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") replace
order(pa10lag lnintens intpa deminit lospol lospol2)
;
#del cr;

***************************************************************

** Results are robust to substituting COW deaths data

***************************************************************

replace cowdeaths=deaths if cowdeaths==. /* otherwise have missing data for component conflicts of disaggregated wars */

stset cowdeaths
stcox pa10lag terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
eststo model1
stcox pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
eststo model2
stcox pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
eststo model3
stset cowdeaths, f(conquest==0)
stcrreg pa10lag lnintens lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest)
eststo model4
stset cowdeaths, f(conquest)
stcrreg pa10lag lnintens lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest==0)
eststo model5

#del ;
esttab model1 model2 model3 model4 model5 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.3" "2.2.4" "2.3.2" "2.4.4" "2.4.5") sca(N_fail)
title("Deaths Analysis Robustness Checks (COW Death Data)\label{tab-robust-cowdeaths}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag lnintens deminit lospol lospol2)
;
#del cr;

*********************************************************************

** Results are robust when using alternate measures of military conquest

*********************************************************************

stset durat, f(conquest2==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest2)
eststo model1

stcrreg pa10lag lnintens intpa lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest2)
eststo model2

stset durat, f(conquest2)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest2==0)
eststo model3

stset deaths, f(conquest2==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest2)
eststo model4

stset deaths, f(conquest2)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest2==0)
eststo model5

probit conquest2 pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale if default==1, robust
eststo model6

#del ;
esttab model1 model2 model3 model4 model5 model6 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.4.1" "2.4.2" "2.4.3" "2.4.4" "2.4.5" "2.5.5") sca(N_fail)
title("Robustness Checks Using the Restrictive Coding of Military Conquest\label{tab-robust-conqrestrict}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag lnintens deminit lospol)
;
#del cr;

stset durat, f(conquest3==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest3)
eststo model1

stcrreg pa10lag lnintens intpa lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest3)
eststo model2

stset durat, f(conquest3)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest3==0)
eststo model3

stset deaths, f(conquest3==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest3)
eststo model4

stset deaths, f(conquest3)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest3==0)
eststo model5

probit conquest3 pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale if default==1, robust
eststo model6

#del ;
esttab model1 model2 model3 model4 model5 model6 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.4.1" "2.4.2" "2.4.3" "2.4.4" "2.4.5" "2.5.5") sca(N_fail)
title("Robustness Checks Using the Expansive Coding of Military Conquest\label{tab-robust-conqexpand}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag lnintens deminit lospol)
;
#del cr;

********************************************************************

** Alternate tests of the intensity argument

********************************************************************

stset durat, f(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
eststo model1
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1 & durat<365, robust nohr compete(conquest)
eststo model2
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1 & durat<365 & conquest==0, robust nohr
eststo model3
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1 & durat>=365, robust nohr compete(conquest)
eststo model4

#del ;
esttab model1 model2 model3 model4 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.4.1" "$<1$ yr." "$<1$ yr." "$>1$ yr.") sca(N_fail)
title("Alternate Approach to Testing the Effects of War Intensity\label{tab-robust-intensity}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag lnintens deminit lospol)
;
#del cr;

********************************************************************

** Robustness checks related to the regime variables

********************************************************************

** Claim 1: Results are robust to substituting alternate approaches to determining lospol in multilateral conflicts
** For the main analysis, this only matters for the Palestine War, as the other examples (WWII, Vietnam) are 
** disaggregated in ways that avoid the problem (Germany and Japan lose separate wars, for example).  I thus do
** not present robustness checks here, as the results are minimally different.

** Claim 2: Results are weaker when substituting the initiator's Polity score for the democracy dummy.

stset durat
stcox pa10lag lnintens polityinit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
eststo model1
stset deaths
stcox pa10lag lnintens polityinit lospol terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
eststo model2

** Claim 3: There is no evidence of a non-linear effect of losing regime type in the competing risks regressions

stset durat, f(conquest==0)
stcrreg pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
eststo model3

stset deaths, f(conquest==0)
stcrreg pa10lag lnintens deminit lospol lospol2 terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest)
eststo model4

** Claim 4: Results hold up substituting a different threshold (Polity=6) for a democratic initiator.
** Only two cases change under this robustness check: the Roman Republic War and the Second Spanish-
** Moroccan War.  Both are relatively short and not particularly deadly, and thus are in line with
** the expectation that wars initiated by democracies will be shorter.  Replications of table 2.2 
** thus produce stronger results; the variable remains typically insignificant in table 2.4, however.
** Given the limited changes, I do not reproduce the findings (which can be generated by substituting
** deminit6 for deminit in the relevant regressions) here.

#del ;
esttab model1 model2 model3 model4 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.2" "2.2.4" "2.4.1" "2.4.4") sca(N_fail)
title("Robustness Checks Related to the Measurement of Regime Variables\label{tab-robust-regime}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag lnintens deminit polityinit lospol lospol2)
;
#del cr;



*********************************************************************

** Robustness checks related to GDP for the maneuver analysis

*********************************************************************

probit maneuver demin terrain contig relcap nstates majpowboth stratexp irst if default==1, robust
eststo model1

probit omda demin terrain contig relcap nstates majpowboth stratexp irst if default==1, robust
eststo model2

probit maneuver demin terrain contig relcap nstates majpowboth stratexp energy if default==1, robust
eststo model3

probit omda demin terrain contig relcap nstates majpowboth stratexp energy if default==1, robust
eststo model4

** Checking GDP requires merging in Maddison data
rename ccode1 ccode
merge m:1 ccode year using GDPdata, keepus(GDP)
rename GDP gdp1
drop if _merge==2
drop _merge
rename ccode ccode1
rename ccode2 ccode
merge m:1 ccode year using GDPdata, keepus(GDP)
rename GDP gdp2
drop if _merge==2
drop _merge
rename ccode ccode2
gen gdp=gdp1+gdp2

lab var gdp "GDP"

probit maneuver pa10lag demin terrain contig relcap nstates majpowboth stratexp gdp if default==1, robust
eststo model5

probit omda pa10lag demin terrain contig relcap nstates majpowboth stratexp gdp if default==1, robust
eststo model6

#del ;
esttab model1 model2 model3 model4 model5 model6 using appendix_tables.tex, tex b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.5.2" "2.5.3" "2.5.2" "2.5.3" "2.5.2" "2.5.3")
title("Robustness Checks Using Alternate Measures of Economic Development, Maneuver Analysis\label{tab-robust-maneuvGDP}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") append
order(pa10lag irst energy gdp)
;
#del cr;

*********************************************************************

** Results are robust to using different statistical specifications

*********************************************************************

stset durat

streg pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(w) nohr
eststo weib21

streg pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(w) nohr
eststo weib22

streg pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(logn)
eststo logn21

streg pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(logn)
eststo logn22

#del ;
esttab weib21 weib22 logn21 logn22 using appendix_extension.tex, replace tex
b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.1" "2.2.2" "2.2.1" "2.2.2") sca("N_fail Wars")
title("Alternate Specifications for Analysis of War Duration (Parametric Specifications)\label{tab-robust-parametric1}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$")
order(pa10lag lnintens deminit lospol)
;
#del cr; 

stset deaths

streg pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(w) nohr

streg pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(w) nohr
eststo weib24

streg pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(logn)

streg pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust d(logn)
eststo logn24

gen lndeaths=log(deaths)

reg lndeaths pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust
eststo ols23

reg lndeaths pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust
eststo ols24

nbreg deaths pa10lag terrain contig relcap nstates durscale majpowboth civclash if default==1, robust
eststo nb23

nbreg deaths pa10lag lnintens deminit lospol terrain contig relcap nstates durscale majpowboth civclash if default==1, robust
eststo nb24

#del ;
esttab weib24 logn24 ols23 ols24 nb23 nb24 using appendix_extension.tex, append tex
b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.4" "2.2.4" "2.2.3" "2.2.4" "2.2.3" "2.2.4") sca("N_fail Wars")
title("Alternate Specifications for Analysis of Total Battle Deaths \label{tab-robust-parametric2}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$")
order(pa10lag lnintens deminit lospol)
;
#del cr;

stset durat, f(conquest==0)

stcox pa10lag terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
eststo cox41

stcox pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr 
eststo cox42

stset deaths, f(conquest==0)

stcox pa10lag terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
eststo cox43

stcox pa10lag lnintens deminit lospol terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr 
eststo cox44

use logics_warcost, clear

lab var pa10lag "Capability Shift"
lab var lnintens "Intensity"
lab var deminit "Democratic Initiator"
lab var terrain "Terrain"
lab var contig "Contiguity"
lab var relcap "Relative Capabilities"
lab var nstates "\# of War Participants"
lab var majpowboth "Major Power War"
lab var allyGDP "Total GDP of Allies"
lab var gdpest "Own GDP"

stset warpc

streg pa10lag terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr d(w)

streg pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr d(w)
eststo weib26

streg pa10lag terrain contig relcap nstates allyGDP gdpest, cluster(warnum) d(logn)

streg pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdpest, cluster(warnum) d(logn)
eststo logn26

stset warpc, f(conquest==0)

stcox pa10lag terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr
eststo cox45

stcox pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdpest, cluster(warnum) nohr
eststo cox46

reg warpc pa10lag terrain contig relcap nstates allyGDP gdpest, cluster(warnum)
eststo ols25

reg warpc pa10lag lnintens deminit terrain contig relcap nstates allyGDP gdpest, cluster(warnum)
eststo ols26

#del ;
esttab weib26 logn26 ols25 ols26 using appendix_extension.tex, append tex
b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.2.6" "2.2.6" "2.2.5" "2.2.6") sca("N_fail Wars")
title("Alternate Specifications for Analysis of Government Spending\label{tab-robust-parametric3}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") 
order(pa10lag lnintens deminit lospol)
;
#del cr;

#del ;
esttab cox42 cox44 cox46 using appendix_extension.tex, append tex
b(a2) se l star(\dag .1 * .05 ** .01) 
mtitles("2.4.1" "2.4.4" "2.4.6") sca("N_sub Wars" "N_fail Settlements")
title("Censored Cox in Lieu of Competing Risks Analysis (Table 2.4)\label{tab-robust-crtocox}")
nonotes addnotes("Robust standard errors, $\dag < .1$, \sym{*}$<.05$,\sym{**}$<.01$") 
order(pa10lag lnintens deminit)
;
#del cr;

*********************************************************************

** Robustness checks for control variables

*********************************************************************

** Specifically, I examine alternate specifications for contiguity, major power war, 
** military strategy, and difference.  Because presenting tables for all these results
** would be overwhelming, even in a supplemental appendix, I simply list representative
** tests below, which can be run on the main data to verify the claims made in the book.
** Specifically, these tests involve substituting majpowin for majpowboth, substituting
** conttype for contig, substituting strategy dummies for the Bennett and Stam durscale
** variable, and substituting polclash1 and polclash2 (ideological difference) for 
** civclash (cultural difference).

log using extra_robustness_checks.log, replace

use logics_of_war.dta, clear

** base duration model (Table 2.2, model 2)

stset durat

stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 if default==1, robust nohr

** base deaths model (Table 2.2, model 4)

stset deaths

stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash totalpop if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash totalpop if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 totalpop if default==1, robust nohr
stcox pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 totalpop if default==1, robust nohr

** competing risks duration models

stset durat, f(conquest==0)

stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 if default==1, robust nohr compete(conquest)

stset durat, f(conquest)

stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 if default==1, robust nohr compete(conquest==0)

** competing risks deaths models

stset deaths, f(conquest==0)

stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash totalpop if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash totalpop if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 totalpop if default==1, robust nohr compete(conquest)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 totalpop if default==1, robust nohr compete(conquest)

stset deaths, f(conquest)

stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain conttype relcap nstates majpowboth durscale civclash totalpop if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowin durscale civclash totalpop if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth omda oadm oadp opda civclash totalpop if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash1 totalpop if default==1, robust nohr compete(conquest==0)
stcrreg pa10lag lnintens lospol deminit terrain contig relcap nstates majpowboth durscale polclash2 totalpop if default==1, robust nohr compete(conquest==0)

log close
